/**
 * 
 */
package com.gooex.web.struts.intercepter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.c4j.system.web.exception.ServiceException;

import com.gooex.service.base.exception.ExceptionCode;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author Adolf
 */
public class WebExceptionIntercepter extends AbstractInterceptor {
	private static final long serialVersionUID = -3910413320411516830L;

	private Log logger = LogFactory.getLog(WebExceptionIntercepter.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
	 */
	@Override
	public String intercept(ActionInvocation invoke) throws Exception {
		try {
			return invoke.invoke();
		} catch (ServiceException e) {
			throw e;
		} catch (Exception e) {
			logger.error("", e);
			throw new ServiceException(ExceptionCode.SYSTEM_BUSY_ERROR, "");
		}
	}

}
